import './index.scss';
import navBottom from '../common/nav-bottom.vue'
import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
export default {
  name: 'userhome',
  components: {
    navBottom
  },
  data () {
    return {
      userId: '',
      userEv: {
        eventNumber: '',
        headUrl: '',
        integral: '',
        nickname: '',
        totalMoney: '',
        unreadMsg: '',
        name: ''
      }
    }
  },
  mounted () {
  	let openid = sessionStorage.getItem("openid")
    if (openid == null || openid == '' || openid == 'undefined') {
      sessionStorage.setItem('openid', this.$route.query.openId)
      sessionStorage.setItem('userId', this.$route.query.userId)
      sessionStorage.setItem('wxAvatar', this.$route.query.wxAvatar)
      sessionStorage.setItem('nickName', this.$route.query.nickName)
    }
    if (this.$emit('ifOpenid')) {
      this.$emit('ifOpenid', this.$route.path)
    }
    this.userId = window.sessionStorage.getItem('userId')
    http.post(CONSTANT.WECHATUSER, {userId: this.userId}, (res) => {
      console.log(res)
      if (res.code == 200) {
        this.userEv = res.obj
        if (this.userEv.headUrl == '') {
          this.userEv.headUrl = window.sessionStorage.getItem('wxAvatar')
        }
        if (this.userEv.nickname == '') {
          this.userEv.nickname = window.sessionStorage.getItem('nickName')
        }
        if (this.userEv.name == '') {
          this.userEv.name = this.userEv.nickname
        }
      }
    })
  },
  methods: {
    goTogetherDonate () {
      this.$router.push({path: '/loveRoad'})
    },
    // gotogetherDonate () {
    //   this.$router.push({path: '/togetherDonate'})
    // },
    // togetherWelfare() {
    //   this.$router.push({path: '/togetherWelfare'})
    // },
    // togetherShop() {
    //   this.$router.push({path: '/togetherShop'})
    // },
    guozhenDetails() {
      this.$router.push({path: '/guozhenDetails'})
    },
    goloveRoad () {
      this.$router.push({path: '/loveRoad'})
    },
    goAboutqqc (e) {
      if (e == 'guanyu') {
        this.$router.push({path: '/aboutqqc', query: {witchOne: 'guanyu'}})
      } else if (e == 'tiaokuan') {
        this.$router.push({path: '/aboutqqc', query: {witchOne: 'tiaokuan'}})
      }
    }
  }
}
